package com.bsoft.rpc.basic.codec;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;

import java.nio.charset.Charset;

/**
 * 服务端处理类
 */
@Slf4j
public class NettyServerHandler extends SimpleChannelInboundHandler<MsgProtocol> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, MsgProtocol message) throws Exception {
        log.info("========>接收到客户端请求<========= ");

        String msg = new String(message.getContent(), Charset.forName("utf-8"));

        log.info("消息内容：{}", msg);
        log.info("消息长度：{}", msg.length());
    }
}
